from django.contrib.auth.models import User
from django.db import models
from tinymce import models as tinymce_models


# Create your models here.
class new(models.Model):
    title = models.CharField(max_length=20)
    content = tinymce_models.HTMLField(verbose_name='内容', blank=True, null=True)
    faburen = models.ForeignKey(User, on_delete=models.CASCADE)
    addtime = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.title

    class Meta:
        verbose_name = '资讯'
        verbose_name_plural = '资讯管理'
        ordering = ['-addtime']

class tool_beiwang(models.Model):
    title = models.CharField(max_length=20,verbose_name='标题')
    add_user = models.ForeignKey(User, on_delete=models.CASCADE)
    content = tinymce_models.HTMLField(verbose_name='详情', blank=True, null=True)
    addtime = models.DateTimeField(auto_now_add=True,verbose_name='添加时间')
    leixing = models.CharField(max_length=20,verbose_name='类型',choices=[("未设置","未设置"), ("日程","日程"), ("待办","待办")], default="未设置")
    tixing_time = models.CharField(max_length=20,verbose_name='提醒时间',blank=True,null=True)
    #chaosong=models.ManyToManyField(User,related_name='chaosong',blank=True)



    def __str__(self):
        return self.title

    class Meta:
        verbose_name = '工具-备忘录'
        verbose_name_plural = '工具-备忘录'
        ordering = ['-addtime']

class tool_user_zhanneixin(models.Model):
    title = models.CharField(max_length=20,verbose_name='标题')
    add_user = models.ForeignKey(User, on_delete=models.CASCADE)
    content = tinymce_models.HTMLField(verbose_name='详情', blank=True, null=True)
    addtime = models.DateTimeField(auto_now_add=True,verbose_name='添加时间')
    leixing = models.CharField(max_length=20,verbose_name='类型',choices=[("未设置","未设置"), ("日程","日程"), ("待办","待办")], default="未设置")
    jieshouren=models.ManyToManyField(User,related_name='jieshouren',blank=True,verbose_name='接收人')

    def __str__(self):
        return self.title
    class Meta:
        verbose_name = '工具-站内信'
        verbose_name_plural = '工具-站内信'
        ordering = ['-addtime']

class tool_zhanneixin_zhuangtai(models.Model):
    xinxi = models.ForeignKey(tool_user_zhanneixin, on_delete=models.CASCADE)
    zhaungtai = models.CharField(max_length=20,verbose_name='阅读状态',default='未读',choices=[('已读','已读'), ('未读','未读')])
    add_user = models.ForeignKey(User, on_delete=models.CASCADE)


    def __str__(self):
        return self.xinxi.title

    class Meta:
        verbose_name = '工具-站内信状态'
        verbose_name_plural = '工具-站内信状态'